#pragma once

#include "file/file.h"

struct animtrack_t
{
	uint32			node_index;
	vector<float3>	positions;
	vector<float4>	rotations;
	vector<float3>	scales;
#ifdef LEO_DESIGNER
	void save(file_t& f);
#endif
	void load(file_t& f);

};
struct animation_t
{
	vector<animtrack_t> tracks;
	float timescale;
	float length;
	stringhash name;

	bool operator ==(const stringhash& name) const
	{
		return this->name==name;
	}
#ifdef LEO_DESIGNER
	void save(file_t& f);
#endif
	void load(file_t& f);

};

struct animationcontainer_t
{
	typedef vector<animation_t> animcollection_t;
	animcollection_t anims;

	animation_t* get_anim(const stringhash& animname)
	{
		animcollection_t::iterator it=std::find(anims.begin(),anims.end(),animname);

		if (it==anims.end())
			return NULL;

		return &*it;
	}

	float get_anim_length(const stringhash& animname)
	{
		animation_t* anim=get_anim(animname);
		if (anim)
			return anim->length;

		return 0;
	}

#ifdef LEO_DESIGNER
	void save(file_t& f);
#endif
	void load(file_t& f);
};